package org.trader.proj.Action;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;
import org.springframework.stereotype.Controller;
import org.trader.proj.Pojo.TblUser;
import org.trader.proj.Service.TblUserService;
@Controller//spring Struts2Action注解方式支持，再struts中只用class：userLoginAction
public class UserLoginAction {
	@Resource
	private TblUserService tblUserService;
	private String returnJson;
	
	public String getReturnJson() {
		return returnJson;
	}

	public void setReturnJson(String returnJson) {
		this.returnJson = returnJson;
	}

	public String userLogin(){
		//在struts2中要获得request和session对象要用这样的方法
		HttpServletRequest request = ServletActionContext.getRequest();
		HttpSession session = request.getSession();
		TblUser tblUser = tblUserService.getUser("admin", "admin");
		if (tblUser!=null) {
			returnJson = "{result:'登陆真的！！？？成功！'}";
		}else {
			returnJson = "{result:'登陆失败！'}";
		}
		return "success";
	}

}
